package com.example.demo.imagemanage.service.impl;

import com.example.demo.imagemanage.mapper.ImageMapper;
import com.example.demo.imagemanage.service.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ImageServiceImpl implements ImageService {
    @Autowired
    private ImageMapper imageMapper;

    /**
     * @Description 通过厂家和产品查询所有图片
     * @Author zhangxue
     * @Date 17:34 2018/7/11
     * @Param
     * @retrun
     **/
    @Override
    public Map<String, Object> queryImagesByFIDAndPID(Map<String, Object> param) {
        List<Map<String,Object>> resultList = new ArrayList<Map<String,Object>>();
        resultList = imageMapper.queryImagesByFIDAndPID(param);
        Map<String,Object> resultMap = new HashMap<String, Object>();
        resultMap.put("data",resultList);
        return resultMap;

    }

    /**
     * @Description 查询厂家下拉框
     * @Author zhangxue
     * @Date 17:34 2018/7/11
     * @Param
     * @retrun
     **/
    @Override
    public Map<String, Object> changeFactory(Map<String, Object> param) {
        List<Map<String,Object>> resultList = new ArrayList<Map<String,Object>>();
        resultList = imageMapper.changeFactory(param);
        Map<String,Object> resultMap = new HashMap<String, Object>();
        resultMap.put("data",resultList);
        return resultMap;

    }

    /**
     * @Description 查询产品下拉框
     * @Author zhangxue
     * @Date 17:34 2018/7/11
     * @Param
     * @retrun
     **/
    @Override
    public Map<String, Object> changeProduct(Map<String, Object> param) {
        List<Map<String,Object>> resultList = new ArrayList<Map<String,Object>>();
        resultList = imageMapper.changeProduct(param);
        Map<String,Object> resultMap = new HashMap<String, Object>();
        resultMap.put("data",resultList);
        return resultMap;

    }

    /**
     * @Description 上传图片
     * @Author zhangxue
     * @Date 17:34 2018/7/11
     * @Param
     * @retrun
     **/
    @Override
    public Map<String, Object> uploadImage(Map<String, Object> param) {
        int i = imageMapper.uploadImage(param);
        Map<String,Object> resultMap = new HashMap<String, Object>();
        if(i==1){
            resultMap.put("status","1");
        }else{
            resultMap.put("status","0");
        }
        return resultMap;

    }

    @Override
    public List<Map<String, Object>> queryAllStyle(Map<String, Object> param) {
        List<Map<String,Object>> resultList = new ArrayList<Map<String, Object>>();
        resultList = imageMapper.queryAllStyle(param);
        return resultList;
    }

    @Override
    public List<Map<String, Object>> queryAllType(Map<String, Object> param) {
        List<Map<String,Object>> resultList = new ArrayList<Map<String, Object>>();
        resultList = imageMapper.queryAllType(param);
        return resultList;
    }

    /**
     * @Description 通过风格和品类查询所有图片
     * @Author zhangxue
     * @Date 17:34 2018/7/11
     * @Param
     * @retrun
     **/
    @Override
    public Map<String, Object> queryAllImageByStyleAndType(Map<String, Object> param) {
        List<Map<String,Object>> resultList = new ArrayList<Map<String,Object>>();
        resultList = imageMapper.queryAllImageByStyleAndType(param);
        Map<String,Object> resultMap = new HashMap<String, Object>();
        resultMap.put("data",resultList);
        return resultMap;

    }

    @Override
    public Map<String, Object> delectImageByID(Map<String, Object> param) {
        int i = imageMapper.delectImageByID(param);
        Map<String,Object> resultMap = new HashMap<String, Object>();
        if(i==1){
            resultMap.put("status","1");
        }else{
            resultMap.put("status","0");
        }
        return resultMap;
    }
}
